//
//  UIButton+Extension.swift
//  微博009
//
//  Created by Romeo on 15/9/5.
//  Copyright © 2015年 itheima. All rights reserved.
//

import UIKit

extension UIButton {
    
    /// 便利构造函数
    ///
    /// - parameter title:     title
    /// - parameter imageName: imageName
    /// - parameter color:     color
    /// - parameter fontSize:  fontSize
    ///
    /// - returns: UIButton
    convenience init(title: String, imageName: String, color: UIColor, fontSize: CGFloat) {
        self.init()
        
        setTitle(title, forState: UIControlState.Normal)
        setImage(UIImage(named: imageName), forState: UIControlState.Normal)
        setTitleColor(color, forState: UIControlState.Normal)
        
        titleLabel?.font = UIFont.systemFontOfSize(fontSize)
        
        
    }
    
    /// 便利构造函数
    /// 返回一个button
    /// - parameter imageName: imageName
    convenience init (imageName:String){
        self.init()
    
        setImage(UIImage(named: imageName), forState: UIControlState.Normal)
         setImage(UIImage(named: imageName + "_highlighted"), forState: UIControlState.Highlighted)
        
        
        sizeToFit()
    }

}
